from manim import *

class GaokaoBlessing(Scene):
    def construct(self):
        # 设置背景颜色
        self.camera.background_color = "#FFFFFF"
        
        # 创建心形曲线公式
        formula = MathTex(
            r" x = 16\sin^3(t), \quad y = 13\cos(t) - 5\cos(2t) - 2\cos(3t) - \cos(4t) ",
            color=BLACK
        ).scale(0.8).to_edge(UP)

        # 显示心形曲线公式
        self.play(Write(formula))
        self.wait(2)

        # 创建心形曲线
        heart_curve = ParametricFunction(
            lambda t: np.array([
                16 * np.sin(t)**3,
                13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t),
                0
            ]), t_range=np.array([0, TAU]), color=RED
        ).scale(0.25).shift(UP*2)

        # 显示心形曲线
        self.play(Create(heart_curve),run_time=6)
        self.wait(1)

        # 创建“金榜题名”文字
        text = Text("心若止水", font="SimHei", color=GOLD).scale(0.8).move_to(heart_curve.get_center())

        # 创建祝福语
        blessing = Text("祝所有考生高考顺利！", font="SimHei", color=BLUE).next_to(text, DOWN, buff=0.2).scale(0.6)

        # 逐渐显示“金榜题名”文字
        self.play(Write(text))
        self.wait(1)

        # 显示祝福语
        self.play(FadeIn(blessing))
        self.wait(3)

        # 整体淡出
        self.play(FadeOut(text), FadeOut(blessing), FadeOut(heart_curve), FadeOut(formula))

        # 结束动画
        self.wait(1)